#include "TileHandler.h"

	const int TileHandler::ROCK		= 1;
	const int TileHandler::GRASS	= 2;
	const int TileHandler::SAND		= 3;
	const int TileHandler::TILES	= 4;
	const int TileHandler::BANANA	= 5;
	const int TileHandler::WOOD		= 6;
	const int TileHandler::ICE		= 7;

TileHandler::TileHandler()
{
	sf::Image * img = new sf::Image();
	img->LoadFromFile("images/rock.png");
	Tile * rock = new Tile("Rock",ROCK,img);
	tiles.insert(std::make_pair(ROCK,rock));
}

TileHandler::~TileHandler()
{


}

void TileHandler::draw(float x,float y,float scale,int tileID,sf::RenderWindow *rw)
{
	Tile *tempTile;
	if(getTile(tileID,tempTile))
	{
		rw->Draw(*tempTile->getDrawSprite(x,y,scale));
	}
	else
	{
		std::cout<<"Tile ID " << tileID << " not found!"; 
	}
}

bool TileHandler::getTile(int ID,Tile* &tempTile)
{
	std::map<int, Tile*>::iterator it;
	it = tiles.find(ID);
	if(it == tiles.end())
	{
		return false;
	}
	else
	{
		tempTile = it->second;
	}
	return true;
}

